<?php $this->load->view('layout/header'); ?>
<div class="container-fluid">
    <div class="span12">
        <h3 class="page-title">旅游产品
            <small> 商品管理</small>
        </h3>
        <?php echo breadcrumb(array('tourismgoods/grid' => '旅游产品', "tourismgoods/images" => '图片管理')); ?>
    </div>
    <?php echo execute_alert_message() ?>
    <div class="row-fluid">
        <div class="span12">
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-reorder"></i>图片管理</div>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                        <a href="javascript:;" class="remove"></a>
                    </div>
                </div>
                <div class="portlet-body" style="display: block;">
                    <div class="row-fluid">
                        <div class="span4"></div>
                        <div class="span8">
                            <form class="line-form" action="<?php echo base_url('tourismgoods/saveImages'); ?>"
                                  method="post" enctype="multipart/form-data">
                                <div class="pull-left">
                                    <input type="hidden" name="goods_id" value="<?php echo $this->uri->segment(3) ?>"/>
                                    <input type="file" name="images[]" class="checkPicture required" multiple="multiple"/>
                                    <button class="btn green" type="submit"><i class="icon-plus"></i> 上传</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <hr class="clearfix"/>
                    <?php if ($images->num_rows() > 0) : $i = 1 ?>
                        <?php foreach ($images->result() as $val) : ?>
                            <?php if (($i - 1) % 4 == 0) : ?><div class="row-fluid"><?php endif; ?>
                            <div class="span3">
                                <div class="item" style="height:248px">
                                    <a target="_blank" href="<?php echo $this->config->show_image_url('tourism', $val->images); ?>">
                                        <div class="zoom">
                                            <img src="<?php echo $this->config->show_image_url('tourism', $val->images); ?>" width="373" height="248">
                                        </div>
                                    </a>
                                    <div class="details">
                                        <a href="<?php echo base_url('tourismgoods/deleteImage/' . $val->id . '?goods_id=' . $val->goods_id . '&image_name=' . $val->images) ?>" class="icon" onclick="return confirm('确定要删除？')">删除</a>
                                        <?php if ($val->is_main == 0): ?>
                                            <a href="<?php echo base_url('tourismgoods/mainImage/' . $val->id . '?goods_id=' . $val->goods_id . '&image_name=' . $val->images) ?>" class="icon" onclick="return confirm('确定要将此图片设置为默认图片？')">设成默认</a>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                            <?php if ($i % 4 == 0 || $i == $images->num_rows()) : ?></div><?php endif; ?>
                        <?php $i++;endforeach ?>
                    <?php endif ?>
                </div>
            </div>
        </div>
    </div>
</div>
<!--
<div class="row cl">
    <label class="form-label col-xs-3 col-sm-3">简介图片：</label>
    <div class="formControls col-xs-6 col-sm-6">
        <div class="controls">
            <div class="file-image thumbnail" style="width: 110px; height: 110px;">
                <img src="{:imageUrlOrOldUrl(@$vo.content_url, true)}" width="100" height="100"/>
            </div>
            <input type="file" name="content_url"/>
            <input type="hidden" name="content_url" value="{$vo.content_url ?? ''}"/>
        </div>
    </div>
    <div class="col-xs-3 col-sm-3"></div>
</div>
-->
<?php $this->load->view('layout/footer'); ?>
<script type="text/javascript">
    $('#form').on('change', 'input[type=file]', function (e) {
        var $this = $(this);
        upLoadImg(e.currentTarget.files[0], function (obj) {
            console.log(obj);
            $this.siblings('[type=hidden]').val(obj.save_path);
            $this.siblings('.file-image').children('img').attr('src', obj.file_url);
        });
    });
</script>
